﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PJRScrum
{
    public partial class ImportGuiPanelOne : ImportGuiPanel
    {

        List<string> winkelLijst;

        public ImportGuiPanelOne()
        {
            InitializeComponent();
            winkelLijst = View.GetInstance().LaadAlleWinkels();
            buttonWinkelOpslaan.Click += new EventHandler(buttonWinkelOpslaan_Click);

            //Auto complete string shine
            txt_stadsNaam.Text = "";
            buttonWinkelOpslaan.Visible = true;
            AutoCompleteStringCollection col = new AutoCompleteStringCollection();
            string[] s = winkelLijst.ToArray();

            for (int i = 0; i < s.Length; i++)
            {
                col.Add(s[i]);
            }
            txt_stadsNaam.AutoCompleteCustomSource = col;
        }

        void buttonWinkelOpslaan_Click(object sender, EventArgs e)
        {
            //Moet nog gebeuren.... of niet
        }

        public string GetStadsNaam()
        {
            return txt_stadsNaam.Text;
        }

        class IgnoreCaseComparer : IEqualityComparer<string>
        {
            public bool Equals(string x, string y)
            {
                if (x != null)
                    return y != null ? x.ToLower().Equals(y.ToLower()) : false;
                if (y != null)
                    return x != null ? x.ToLower().Equals(y.ToLower()) : false;
                return true;
            }

            public int GetHashCode(string obj)
            {
                return obj != null ? obj.GetHashCode() : 0;
            }
        }
        IgnoreCaseComparer MyComparer = new IgnoreCaseComparer();
        public override bool Finished
        {
            get
            {
                return winkelLijst.Contains(txt_stadsNaam.Text, MyComparer);
            }
        }
    }
}
